//
//  MYXVisitorViewController.swift
//  weibo
//
//  Created by MaYingxin on 16/4/17.
//  Copyright © 2016年 MaYingxin. All rights reserved.
//

import UIKit

class MYXVisitorViewController: UITableViewController {

    var isLogin: Bool = false
    
    var vistorView: MYXVistorView?
    
    override func loadView() {
        
        isLogin ? super.loadView() : setVistorView()
    }
    
    @objc private func login(){
        
        let loginVc = MYXLoginViewController()
        
        presentViewController(UINavigationController(rootViewController: loginVc), animated: true, completion: nil)
    }
    
    private func setNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Done, target: self, action: "login")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
    }
    
    private func setVistorView(){
        
        setNav()
        vistorView = MYXVistorView()
        
        vistorView?.vistorClosure = {
            
            self.login()
        }
        
        view = vistorView
    }
    
}
